/**
 * Copyright (C) 2010 Alfredo Morresi
 * 
 * This file is part of WebcamHolmes project.
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * 
 */
package it.rainbowbreeze.libs.logic;

import android.content.Context;
import android.os.Handler;

import static it.rainbowbreeze.libs.common.RainbowContractHelper.*;

/**
 * Executes begin thread
 * 
 * @author Alfredo "Rainbowbreeze" Morresi
 *
 */
public class RainbowLogicManagerExecuteBeginTasksThread
	extends RainbowBaseBackgroundThread<Void>
{

	//---------- Private fields
	private final RainbowLogicManager mBaseLogicManager;
	
	//---------- Constructor
	/**
	 * @param context
	 * @param handler
	 * @param logicManager
	 */
	public RainbowLogicManagerExecuteBeginTasksThread(
			Context context,
			Handler handler,
			RainbowLogicManager logicManager) {
		super(context, handler);
		mBaseLogicManager = checkNotNull(logicManager, "LogicManager");
	}


	//---------- Public properties
	public final static int WHAT_EXECUTE_BEGIN_TASK = 1020;


	
	
	//---------- Public methods
	/* (non-Javadoc)
	 * @see it.rainbowbreeze.libs.logic.BaseBackgroundThread#run()
	 */
	@Override
	public void run() {
		mResultOperation = mBaseLogicManager.executeBeginTasks(getContext());
		
		//and call the caller activity handler when the execution is terminated
		callHandlerAndRetry(WHAT_EXECUTE_BEGIN_TASK);		
	}

	//---------- Private methods
}
